import { PluginOption } from 'vite'
import { setupCommPlugins } from './installCommPlugins'
import { setupUIFrameworkPlugins } from './installUIFrameworkPlugins'
import { setupPackageAnalyzerPlugins } from './installPackageAnalyzerPlugins'
import { setupDebugPlugins } from './installDebugPlugins'
import { setupCompressAndRemoveConsolePlugin } from './installCompressAndRemoveConsolePlugin'

/**
 * 打包结果压缩以及console.log代码删除以及低版本浏览器兼容性插件
 * @param command
 * @param mode
 * @param pluginArr
 * @param env
 */
export function setupVitePlugin(
  command: string,
  mode: string,
  pluginArr: (PluginOption | PluginOption[])[],
  env: Record<string, string>,
  version: string
) {
  setupCommPlugins(command, mode, pluginArr, env)
  setupUIFrameworkPlugins(command, mode, pluginArr, env)
  setupPackageAnalyzerPlugins(command, mode, pluginArr, env)
  setupDebugPlugins(command, mode, pluginArr, env)
  setupCompressAndRemoveConsolePlugin(command, mode, pluginArr, env, version)
}
